<template>
  <div class="content-header"><h2><span class="icontitle iconfont iconbiaoti"></span>所有文章</h2><h2>{{ limitConfig.totalCount }} 篇</h2></div>
  <Loading v-if="isload"/>
  <div class="content">
    <div class="article" @click="toArticleDetails(item)" v-for="(item,index) in dataList" :key="index">
      <div class="article-title"><h3><span class="icontitle iconfont iconbiaoti"></span>{{item.articleTitle}}</h3></div>
      <div class="article_img">
        <div class="blog_area">
          <div class="article-contnet">{{ item.articleDescription }}</div>
        </div>
        <div class="blog_img">
          <img :src="item.articleImageurl">
        </div>
      </div>
      <div class="blogdetails_footer">
        <div class="category">
          <span class="label_title iconfont iconcategory">分类:</span>
          <span class="sub_list">{{ item.category.categoryName }}</span>
        </div>
        <div class="tag">
          <span class="label_title iconfont iconbiaoqian">标签:</span>
          <span v-for="(tag,index) in item.tags" class="sub_list">{{ tag.tagName }}</span>
        </div>
        <div class="time">
          <span class="label_title iconfont iconshijian">时间:</span>
          <span class="sub_list">{{ getTime(item.articleDate) }}</span>
        </div>
      </div>
    </div>
  </div>

  <limit-control @receiveData="receiveData" :config="limitConfig"/>
</template>

<script>
import LimitControl from "../../common/LimitControl";
import Loading from "../message/Loading";
export default {
  name: "ContentBody",
  components:{Loading,LimitControl},
  data(){
    return {
      isload:true,
      isdisable:false,
      totalCount:0,
      dataList:[],
      currequest:{
        countUrl: '/backend/front/allarticlecount',
      },
      limitConfig:{
        url:'/backend/front/articledetailslimit',
        countUrl: '/backend/front/allarticlecount',
        pageSize:3,
        pageNo:0,
        totalCount:0,
        receiveData:'receiveData',
        isActivePre:true,
        isActiveNxet:true,
      },
    }
  },
  methods: {
    toArticleDetails(blog) {
      this.$router.push({
        path: `/articledetails/datarequest/${blog.articleId}`,
      })
    },
    receiveData(data) {
      this.dataList = data;
      this.isload = false;
    },
    getTime(time){
      let date = new Date(time);
      let y = date.getFullYear();
      let M = date.getMonth()+1>=10 ? date.getMonth()+1: "0" + (date.getMonth()+1);
      let d = date.getDate()>=10 ? date.getDate(): "0" + date.getDate();
      return y + "-" + M + "-" + d + " ";
    },
  }

}
</script>

<style scoped>
.content-header{
  display: flex;
  justify-content: space-between;
  padding: 1rem;
  color: #000000;
  border-bottom: 3px #cccccc solid;
  box-shadow: 0 0 10px #cccccc;
}
h2,h3{
  font-weight: normal;
}
.icontitle{
  font-size: 1.5rem;
  margin-right: 5px;
  text-shadow: none;
}
.article{
  width: 80%;
  height: 220px;
  padding: 10px;
  background-color: #ddd;
  border-bottom: 1px solid #ccc;
  border-radius: 10px;
  margin: 50px auto;
  /*box-sizing: border-box;*/
  transition: all .5s ease;
  cursor: pointer;
}
.article_img{
  display: flex;
}
.content .article:nth-child(2n) .blog_img{
  order: -1;
}
.blog_area{
  width: 100%;
}
.blog_img{
  width: 260px;
  height: 140px;
  transform: translateY(-20px);
  box-shadow: 0 0 5px #03e9f4;
  border-radius: 5px;
  overflow: hidden;
}
.blog_img img{
  width: 100%;
  height: 100%;
}

.article:hover{
  transform: scale(1.1);
  box-shadow: 0 0 20px #03e9f4;
}
.article-title{
  padding: .5rem;
  margin-bottom: .5rem;
  text-shadow: 3px 3px 5px rgba(0,0,0,.8);
  overflow: auto;
  border-bottom: 3px solid #03e9f4;
}
.content .article:nth-child(2n) .article-title h3{
   float: right;
}

.article-contnet{
  color:#555;
  font-size: 14px;
  text-shadow: 0 0 3px #F7F7F7;
  text-indent: 2em;
  padding: .5rem .2rem;
  padding-bottom: .8rem;
  margin-bottom: .5rem;
  height: 5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}
.blogdetails_footer{
  display: flex;
  justify-content: space-around;
  /*font-size: 14px;*/
}
div> span{
  font-size: 14px!important;
}
.label_title{
  display: inline-block;
  width: 50px;
  border-radius: 5px;
  padding: 0 3px;
  margin-right: 2px;
  text-align: center;
  line-height: 20px;
  box-shadow: 0 0 10px #0077aa;
  background-color: #03e9f4;
}
.sub_list {
  font-size: 14px!important;
  background-color: #1abc9c;
  border-radius: 5px;
  padding: 0 3px;
  margin-right: 2px;
  box-shadow: 0 0 10px #0077aa;
}

@media only screen and (max-width: 960px) {
  .article{
    width: 90%;
  }
  .article:hover{
    transform: scale(1);
    box-shadow: 0 0 20px #03e9f4;
  }
  .tag{
    display: none;
  }

}
</style>